Skip to content

Add pushAnimationMutations to the AnimationBackend#56401

Open
bartlomiejbloniarz wants to merge 1 commit intomainfrom
export-D100164749
Open

Add pushAnimationMutations to the AnimationBackend#56401
bartlomiejbloniarz wants to merge 1 commit intomainfrom
export-D100164749

Conversation

@bartlomiejbloniarz
Copy link
Copy Markdown
Contributor

@bartlomiejbloniarz bartlomiejbloniarz commented Apr 9, 2026

Summary:
Add pushAnimationMutations(Callback) to the AnimationBackend as a targeted alternative to trigger().

The existing trigger() method has two problems:

  1. Blast radius: It calls onAnimationFrame() which invokes ALL registered callbacks. When one animation frontend (e.g. Animated) calls trigger() in response to an event, every other frontend (e.g. Reanimated) also spins up unnecessarily.

  2. Broken timestamp on iOS: trigger() uses std::chrono::steady_clock which on iOS maps to a different kernel clock than what CADisplayLink uses for vsync timestamps. These clocks have different baselines and can diverge over time (e.g. after device sleep), causing animations to see time jumps.

pushAnimationMutations(Callback) fixes both issues:

  • Executes only the provided callback, not all registered ones
  • Uses AnimationChoreographer::now() which delegates to HighResTimeStamp, providing a timestamp from the same clock as the vsync path on each platform

Also refactors onAnimationFrame to use unpackMutations/applySurfaceUpdates helpers, avoiding intermediate vector/set merging when accumulating mutations from multiple callbacks.

Changelog:

[General][Added] - Add pushAnimationMutations to AnimationBackend for targeted event-driven animation updates

Differential Revision: D100164749

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 9, 2026
@facebook-github-tools facebook-github-tools bot added p: Software Mansion Partner: Software Mansion Partner p: Facebook Partner: Facebook labels Apr 9, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Apr 9, 2026

@bartlomiejbloniarz has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100164749.

Summary:
Add `pushAnimationMutations(Callback)` to the AnimationBackend as a targeted alternative to `trigger()`.

The existing `trigger()` method has two problems:

1. **Blast radius**: It calls `onAnimationFrame()` which invokes ALL registered callbacks. When one animation frontend (e.g. Animated) calls `trigger()` in response to an event, every other frontend (e.g. Reanimated) also spins up unnecessarily.

2. **Broken timestamp on iOS**: `trigger()` uses `std::chrono::steady_clock` which on iOS maps to a different kernel clock than what `CADisplayLink` uses for vsync timestamps. These clocks have different baselines and can diverge over time (e.g. after device sleep), causing animations to see time jumps.

`pushAnimationMutations(Callback)` fixes both issues:
- Executes only the provided callback, not all registered ones
- Uses `AnimationChoreographer::now()` which delegates to `HighResTimeStamp`, providing a timestamp from the same clock as the vsync path on each platform

Also refactors `onAnimationFrame` to use `unpackMutations`/`applySurfaceUpdates` helpers, avoiding intermediate vector/set merging when accumulating mutations from multiple callbacks.

## Changelog:
[General][Added] - Add pushAnimationMutations to AnimationBackend for targeted event-driven animation updates

Differential Revision: D100164749
@facebook facebook deleted a comment from github-actions bot Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook p: Software Mansion Partner: Software Mansion Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant